package com.apexsoft.front.common.utils;

import java.io.IOException;
import java.util.Properties;


public class ErrorResource {
	private static Properties pFile = new Properties();

	public static void getInstance() {
		try {
			pFile.load(ErrorResource.class.getResourceAsStream("/error_resource.properties"));
		} catch (IOException e) {
			e.printStackTrace();
			LogUtil.errorLog(ErrorResource.class, e.getMessage(), e);
		}
	}

	public static String getVaue(String key) {
		String value = pFile.getProperty(key);
		if (value == null) {
			return "无错误配置信息[错误编号:"+key+"]";
		} else {
			return value;
		}
	}

	public static String getDynamicVaue(String key, String... params) {
		String value = pFile.getProperty(key);
		if (value == null) {
			return "无错误配置信息[错误编号:"+key+"]";
		} else {
			for (int i = 0; i < params.length; i++) {
				value = value.replace("{" + i + "}", params[i]);
			}
			return value;
		}
	}
}
